import { Entity, Column, PrimaryGeneratedColumn, UpdateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
import { AdPosition } from "./ad_position.entities";
import { ApiProperty} from '@nestjs/swagger';
import { IsOptional } from 'class-validator';
import { User } from './user.entities';

@Entity()
export class Address {
  @PrimaryGeneratedColumn({type: 'mediumint'})
  id: number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'mediumint'})
  user_id:number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar' ,length: 50 , comment: "收货人姓名"})
  user_name: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar' ,length: 60 })
  tel_number: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar' ,length: 50, comment: "邮编" })
  postal_Code: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: "varchar",length:50,comment:"收货地址国家码"})
  national_Code: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar', length: 50,comment:"省"})
  province_Name: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar', length: 50,comment:"市"})
  city_Name: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar', length: 50,comment:"区"})
  county_Name: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar', length: 120,comment:"详细收货地址信息"})
  detail_Info: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'int'})
  is_default: number;

  @ManyToOne(type => User, user => user.address)
  @JoinColumn({
    name: 'user_id'
  })
  user: User
}
